package com.util.property;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取properties配置文件
 * @author reeves
 * @description: 单利模式，调用方法：PropertyReader.getInstance.getProperty("属性名");
 */

public class PropertyReader extends Properties {
    private static  PropertyReader instance;

    public static PropertyReader getInstance () {
        if(null != instance) {
            return instance;
        } else {
            makeInstance();
            return instance;
        }
    }

    private static synchronized void makeInstance() {
        if(instance == null) {
            instance = new PropertyReader();
        }
    }

    private PropertyReader() {
        InputStream is = getClass().getResourceAsStream("/global.properties");
        try {
            load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}